package com.kevin.design.structuralPattern.adapter;
// 双向适配器 实际开发中很少使用
public class DoubleAdapter {
    public static void main(String[] args) {
        TargetD targetD = new AdapterD(new AdapteeX());
        targetD.t2();
        targetD.t1();
    }
}

interface TargetD{
    void t1();
    void t2();
}

interface AdapteeD{
    void a1();
    void a2();
}

class AdapteeX implements AdapteeD{

    @Override
    public void a1() {
        System.out.println("a1");
    }

    @Override
    public void a2() {
        System.out.println("a2");
    }
}

class AdapterD implements TargetD,AdapteeD{
    private TargetD targetD;
    private AdapteeD adapteeD;

    public AdapterD(TargetD targetD) {
        this.targetD = targetD;
    }

    public AdapterD(AdapteeD adapteeD) {
        this.adapteeD = adapteeD;
    }

    @Override
    public void t1() {
        adapteeD.a1();
    }

    @Override
    public void t2() {
        adapteeD.a2();
    }

    @Override
    public void a1() {
        targetD.t1();
    }

    @Override
    public void a2() {
        targetD.t2();
    }
}